package com.example.Lezedata.ui.activity.person;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.Lezedata.R;
import com.example.Lezedata.dataManager.GBUserManager;
import com.example.Lezedata.ui.activity.baseClass.GBBaseVc;
import com.example.Lezedata.util.GBUtil;
import com.wildma.pictureselector.PictureSelector;

public class PersonSetHeadVc extends GBBaseVc {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_person_set_head_vc;
    }

    @Override
    public CharSequence title() {
        return "Upload picture";
    }

    private TextView upload;
    private ImageView head;

    @Override
    protected void viewDidLoad() {
        super.viewDidLoad();

        upload = findViewByTag("upload");
        head = findViewByTag("head");

        String headURL = GBUserManager.userInfo().getProfileUrl();
        if (headURL != null){
            GBUtil.setHeadImage(head,headURL);
        }

        upload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        head.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectHead();
            }
        });
    }

    void selectHead(){
        PictureSelector
                .create(this, PictureSelector.SELECT_REQUEST_CODE)
                .selectPicture(true, 200, 200, 1, 1);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        /*结果回调*/
        if (requestCode == PictureSelector.SELECT_REQUEST_CODE) {
            if (data != null) {
                String picturePath = data.getStringExtra(PictureSelector.PICTURE_RESULT);
            }
        }
    }
    
    void uploadImage(){

    }
}